package com.example.zq.player.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.zq.player.R;
import com.example.zq.player.domain.Cart;

import java.util.List;

/**
 * Created by zq on 2018/12/25.
 */

public class CartAdapter extends ArrayAdapter<Cart> {

    private  int resourceId;
     public CartAdapter(Context context, int textViewResourceId, List<Cart> objects){
         super(context,textViewResourceId,objects);
         resourceId=textViewResourceId;
     }

     public View getView(int position, View convertView, ViewGroup parent){
         Cart cart = getItem(position);
         View view = LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
         ImageView cartImage = (ImageView)view.findViewById(R.id.iv_cart_goods);
         TextView cartName = (TextView)view.findViewById(R.id.tv_cart_goods_name);
         TextView cartDcribe = (TextView)view.findViewById(R.id.tv_cart_goods_decribe);
         TextView cartPrice = (TextView) view.findViewById(R.id.tv_cart_goods_price);
         cartImage.setImageResource(cart.getImageId());
         cartName.setText(cart.getGoodsName());
         cartDcribe.setText(cart.getGoodsDcribe());
         cartPrice.setText(cart.getGoodsPrice());
         return view;
     }
}
